package third.lib.utils;

import java.util.Random;

public class StringRandUtils {
    private static String[] nArr = "0,1,2,3,4,5,6,7,8,9".split(",");
    private static String[] mArr = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(",");
    private static String[] sArr = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(",");

    public static String randNumber(int bit){
        int l = nArr.length;
        Random r = new Random();
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < bit; i++) {
            int rand = r.nextInt(l);
            builder.append(nArr[rand]);
        }
        return builder.toString();
    }

    public static String randChar(int bit){
        int l = sArr.length;
        Random r = new Random();
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < bit; i++) {
            int rand = r.nextInt(l);
            builder.append(sArr[rand]);
        }
        return builder.toString();
    }

    public static String randNumberAndChar(int bit){
        int l = mArr.length;
        Random r = new Random();
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < bit; i++) {
            int rand = r.nextInt(l);
            builder.append(mArr[rand]);
        }
        return builder.toString();
    }
}
